package com.example.javaeefinal.Mapper;

import com.example.javaeefinal.pojo.Role;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @Auther: Xiao Chun
 * @Date: 2023/12/29 14:54
 **/

@Mapper
public interface RoleMapper {
    //    搜索角色
//    根据id搜索角色
    @Select("select f_id as id, f_name as name from t_role where f_id = #{id}")
    public Role getById(Integer id);
    //    根据名字搜索角色
    @Select("select f_id as id, f_name as name from t_role where f_name = #{name}")
    public Role getByName(String name);
    //    返回全部角色
    @Select("select f_id as id, f_name as name from t_role")
    public List<Role> getAll();

    //    新增角色
    @Insert("insert into t_role (f_name) value (#{name})")
    public int add(String name);

    //    删除角色
    @Delete("delete from t_role where f_id = #{id}")
    public int delete(Integer id);

    //    更改角色
//    根据id更改角色名字
    @Update("update t_role set f_name = #{name} where f_id = #{id}")
    public int updateById(@Param("id") Integer id,@Param("name") String name);
}
